Skip to content

[sema] reject inline as { ... } on opaque source types#747

Closed
cs01 wants to merge 3 commits intomainfrom
sema/opaque-inline-cast
Closed

[sema] reject inline as { ... } on opaque source types#747
cs01 wants to merge 3 commits intomainfrom
sema/opaque-inline-cast

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Apr 26, 2026

Before

(x as unknown as { type: string; value: number }) silently passed the type-assertion prefix checker because there's no source interface to compare against. In native code, the inline fields become GEP indices — if they don't match the actual struct layout, it reads wrong memory.

After

Compile error when an inline as { ... } assertion (2+ fields) follows an as unknown, as any, or as object intermediate cast. Suggests using as NamedInterface instead.

Description

Extends type-assertion-checker.ts with a new checkOpaqueSource method. This was the last unaccounted-for hazard in the "Patterns That Crash" list — inline as { ... } on opaque-typed sources where the prefix checker has nothing to verify against. ~30 LOC.

Closes item #3 from #729.

Next Steps

@cs01 cs01 closed this Apr 26, 2026
@cs01 cs01 deleted the sema/opaque-inline-cast branch April 26, 2026 18:58
@cs01
Copy link
Copy Markdown
Owner Author

cs01 commented Apr 26, 2026

closed without merge — stale CI check statuses from cancelled parallel runs prevented merge. reopened as #748 with a clean single-commit branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant